<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="./template.xhtml">

    <ui:define name="head">
        <style type="text/css">
            .ui-treetable table {
                table-layout: fixed
            }
            
            .value {
                font-weight: bold
            }
        </style>
    </ui:define>
    
    <ui:define name="title">
        TreeTable - <span class="subitem">ContextMenu</span>
    </ui:define>

    <ui:define name="description">
        ContextMenu has special integration with TreeTable. Even different menus can be assigned to different node types by matching node types.
    </ui:define>

    <ui:param name="documentationLink" value="/components/treetable" />

    <ui:define name="implementation">
        
        <h:form id="form">            
            <p:treeTable id="docs" value="#{ttContextMenuView.root}" var="document" selectionMode="single" selection="#{ttContextMenuView.selectedNode}">
                <f:facet name="header">
                    Document Viewer
                </f:facet>
                <p:column headerText="Name">
                    <h:outputText value="#{document.name}" />
                </p:column>
                <p:column headerText="Size">
                    <h:outputText value="#{document.size}" />
                </p:column>
                <p:column headerText="Type">
                    <h:outputText value="#{document.type}" />
                </p:column>
            </p:treeTable>
            
            <p:contextMenu for="docs">
                <p:menuitem value="View" update="documentPanel" icon="pi pi-search" oncomplete="PF('documentDialog').show()"/>
                <p:menuitem value="Delete" action="#{ttContextMenuView.deleteNode}" update="docs" icon="pi pi-times"/>
            </p:contextMenu>
            
            <p:dialog id="dialog" header="Document Detail" showEffect="fade" widgetVar="documentDialog" modal="true" resizable="false">
                <p:outputPanel id="documentPanel">
                    <p:panelGrid  columns="2" columnClasses="label,value" rendered="#{not empty ttContextMenuView.selectedNode}">
                        <h:outputLabel for="name" value="Name: " />
                        <h:outputText id="name" value="#{ttContextMenuView.selectedNode.data.name}" style="font-weight:bold" />

                        <h:outputLabel for="size" value="Size: " />
                        <h:outputText id="size" value="#{ttContextMenuView.selectedNode.data.size}" style="font-weight:bold" />

                        <h:outputLabel for="type" value="Type " />
                        <h:outputText id="type" value="#{ttContextMenuView.selectedNode.data.type}" style="font-weight:bold" />
                    </p:panelGrid>
                </p:outputPanel>
            </p:dialog>
        </h:form>
        
    </ui:define>

</ui:composition>